import requests,os
from  lxml import etree
from urllib import request,parse


base_url = 'https://tieba.baidu.com/f?'

def name(msg):
    data = {
        'kw': msg
    }

    newdata = parse.urlencode(data)

    response = request.urlopen(url=base_url+newdata)

    text = response.read().decode('utf-8')
    html = etree.HTML(text)

    res = html.xpath('//ul/li/a/img/@src/')
    print(res)

if __name__ == '__main__':
    while True:
        msg = input("请输入贴吧名:")
        if msg == 'exit':
            break
        name(msg)
